package com.ziven.common.widget.value;

import android.view.View;

import androidx.annotation.NonNull;

import com.ziven.easygo.util.ViewHelper;

/**
 * @author Ziven
 */
public final class IntValue extends Value {

    public static IntValue value() {
        return new IntValue(0);
    }

    public static IntValue value(int init) {
        return new IntValue(init);
    }

    private IntValue(int init) {
        resId = init;
    }

    public IntValue add(int add) {
        resId = resId + add;
        return this;
    }

    public IntValue add() {
        return add(1);
    }

    public IntValue minus(int minus) {
        resId = resId - minus;
        return this;
    }

    public IntValue minus() {
        return minus(1);
    }

    public IntValue and(int and) {
        resId = resId & and;
        return this;
    }

    public IntValue or(int or) {
        resId = resId | or;
        return this;
    }

    public IntValue not() {
        resId = ~resId;
        return this;
    }

    public boolean has(int has) {
        return (resId & has) == has;
    }

    @Override
    protected void takeEffect(@NonNull ViewHelper<? extends View> helper) {
        //Do nothing
    }
}
